package cn.smile.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 拦截器
 *
 * @Author: 毛苏宇
 * User: me
 * Date: 2021/4/22
 * Time: 15:09
 * Description:
 */
public class CustomInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        final String requestURI = request.getRequestURI();
        if (requestURI.contains("/language")) {
            return true;
        } else if (requestURI.contains("/index")) {
            return true;
        } else if (requestURI.contains("/notFound2")) {
            return true;
        } else if (requestURI.contains("/notFound")) {
            response.sendRedirect("/test/notFound2");
            return true;
        }
        return false;
    }
}
